angular.module("app.stat").register.controller("ListP7300Ctrl", ["$scope", "$http", "$state", "$modal", "$modalService", function($scope, $http, $state, $modal, $modalService){
  $scope.stores = [];
  //@formatter:off
  $scope.opts = {
    'statusOpts': [{k: '', t: '请选择'}, {k: 1, t: '成功'}, {k: -1, t: '失败'}]};
  //@formatter:on
  $scope.pager = {
    sizeOpts: [5, 10, 15, 20, 25, 30],
    size: 15,
    maxSize: 5,
    records: 0,
    page: 1,
    onChangeSize: function(){
      $scope.pager.page = 1;
      $scope.gets(1);
    },
    onChange: function(page){
      $scope.gets(page);
    },
    total: function(){
      return Math.ceil($scope.pager.records / $scope.pager.size);
    }
  };
  $scope.openDatepicker = function($event, attr){
    $event.preventDefault();
    $event.stopPropagation();
    $scope[attr] = !0;
  };
  $scope.filter = {
    mt_status: '',
    mobile: '',
    start_date: '',
    end_date: ''
  };
  $scope.getCount = function(){
    $http.post('/stat/hd/count/7300', {
      filter: $scope.filter
    }, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $scope.pager.records = ret.data;
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.gets = function(page){
    $scope.loadTip = '正在获取数据...........';
    $scope.stores = [];
    $http.post('/stat/hd/gets/7300', {
      page: page,
      size: $scope.pager.size,
      filter: $scope.filter
    }, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $scope.stores = ret.data;
        $scope.stores.length == 0 ? $scope.loadTip = '没有找到相关记录！！' : '';
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.download7300 = function(){
    var mt_status = $scope.filter.mt_status;
    var mobile = $scope.filter.mobile;
    var start_date = $scope.filter.start_date;
    var end_date = $scope.filter.end_date;
    location.href = '/stat/hd/download/?mt_status=' + mt_status + '&mobile=' + mobile + '&start_date=' + start_date + '&end_date=' + end_date + '&action=7300';
  };
  $scope.view = function(id){
    $http.post('/stat/hd/detail', {
      id: id
    }, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $scope.entity = ret.data;
        var $modalInstance = $modal.open({
          templateUrl: "/stat/hd/detail",
          controller: "ViewP7300Ctrl",
          backdrop: true,
          size: 'lg',
          resolve: {
            data: function(){
              return $scope.entity;
            }
          }
        });
        $modalInstance.result.then(function(status){
          if(status == 'updated'){
            $scope.refresh();
          }
        }, function(status){
          if(status == 'updated'){
            $scope.refresh();
          }
        });
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.refresh = function(){
    $scope.stores = [];
    $scope.getCount();
    $scope.gets($scope.pager.page);
  };
  $scope.search = function(){
    $scope.pager.page = 1;
    $scope.refresh();
  }
  $scope.getCount();
  $scope.gets(1);
}]);
angular.module("app.stat").register.controller("ViewP7300Ctrl", ["$scope", "$modalInstance", "data", function($scope, $modalInstance, data){
  $scope.entity = data;
  $scope.cancel = function(){
    $modalInstance.dismiss("cancel");
  };
}]);
angular.module("app.stat").register.controller("ListP7288Ctrl", ["$scope", "$http", "$state", "$modal", "$modalService", function($scope, $http, $state, $modal, $modalService){
  $scope.stores = [];
  //@formatter:off
  $scope.opts = {'statusOpts': [{k: '', t: '请选择'}, {k: 1, t: '成功'}, {k: -1, t: '失败'}]};
  //@formatter:on
  $scope.pager = {
    sizeOpts: [5, 10, 15, 20, 25, 30],
    size: 15,
    maxSize: 5,
    records: 0,
    page: 1,
    onChangeSize: function(){
      $scope.pager.page = 1;
      $scope.gets(1);
    },
    onChange: function(page){
      $scope.gets(page);
    },
    total: function(){
      return Math.ceil($scope.pager.records / $scope.pager.size);
    }
  };
  $scope.openDatepicker = function($event, attr){
    $event.preventDefault();
    $event.stopPropagation();
    $scope[attr] = !0;
  };
  $scope.filter = {
    mt_status: '',
    mobile: '',
    start_date: '',
    end_date: ''
  };
  $scope.getCount = function(){
    $http.post('/stat/hd/count/7288', {
      filter: $scope.filter
    }, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $scope.pager.records = ret.data;
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.gets = function(page){
    $scope.loadTip = '正在获取数据...........';
    $scope.stores = [];
    $http.post('/stat/hd/gets/7288', {
      page: page,
      size: $scope.pager.size,
      filter: $scope.filter
    }, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $scope.stores = ret.data;
        $scope.stores.length == 0 ? $scope.loadTip = '没有找到相关记录！！' : '';
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.download7288 = function(){
    var mt_status = $scope.filter.mt_status;
    var mobile = $scope.filter.mobile;
    var start_date = $scope.filter.start_date;
    var end_date = $scope.filter.end_date;
    location.href = '/stat/hd/download/?mt_status=' + mt_status + '&mobile=' + mobile + '&start_date=' + start_date + '&end_date=' + end_date + '&action=7288';
  };
  $scope.view = function(id){
    $http.post('/stat/hd/detail', {
      id: id
    }, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $scope.entity = ret.data;
        var $modalInstance = $modal.open({
          templateUrl: "/stat/hd/detail",
          controller: "ViewP7288Ctrl",
          backdrop: true,
          size: 'lg',
          resolve: {
            data: function(){
              return $scope.entity;
            }
          }
        });
        $modalInstance.result.then(function(status){
          if(status == 'updated'){
            $scope.refresh();
          }
        }, function(status){
          if(status == 'updated'){
            $scope.refresh();
          }
        });
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.refresh = function(){
    $scope.stores = [];
    $scope.getCount();
    $scope.gets($scope.pager.page);
  };
  $scope.search = function(){
    $scope.pager.page = 1;
    $scope.refresh();
  }
  $scope.getCount();
  $scope.gets(1);
}]);
angular.module("app.stat").register.controller("ViewP7288Ctrl", ["$scope", "$modalInstance", "data", function($scope, $modalInstance, data){
  $scope.entity = data;
  $scope.cancel = function(){
    $modalInstance.dismiss("cancel");
  };
}]);